//
//  HJComposeViewController.swift
//  WeiBo
//
//  Created by 韩俊 on 15/12/16.
//  Copyright © 2015年 HanJun. All rights reserved.
//

import UIKit

class HJComposeViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        
        setupUI()
        
    }
    
    private func setupUI(){
        view.backgroundColor = randomColor()
        setupNav()
        
    }
    
    private func setupNav(){
        navigationItem.leftBarButtonItem = UIBarButtonItem( title: "返回", target: self, action: "back")
        navigationItem.rightBarButtonItem = UIBarButtonItem(customView:sendButton)
        navigationItem.rightBarButtonItem?.enabled = false
    }
    //监听事件
    @objc private func back(){
        
        dismissViewControllerAnimated(true, completion: nil)
    }
    
    // MARK: - 懒加载
    /// 发送按钮
    private lazy var sendButton: UIButton = {
        let button = UIButton()
        
        // 设置不同状态的背景图
        button.setBackgroundImage(UIImage(named: "common_button_orange"), forState: UIControlState.Normal)
        button.setBackgroundImage(UIImage(named: "common_button_orange_highlighted"), forState: UIControlState.Highlighted)
        button.setBackgroundImage(UIImage(named: "common_button_white_disable"), forState: UIControlState.Disabled)
        
        // 如果把 button 放在 UIBarButtonItem 里面,其状态由 UIBarButtonItem 控制
        // button.enabled = false
        
        // 设置不同状态的文字颜色
        button.setTitleColor(UIColor.darkGrayColor(), forState: UIControlState.Disabled)
        button.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)
        
        // 设置文字以及其大小
        button.setTitle("发送", forState: UIControlState.Normal)
        button.titleLabel?.font = UIFont.systemFontOfSize(15)
        // 指定其大小
        button.size = CGSize(width: 45, height: 30)
        return button
    }()


    

    
}
